<?php

// +----------------------------------------------------------------------
// |Author: 翼小菜
// +----------------------------------------------------------------------
// |Description: 用户服务逻辑层
// +----------------------------------------------------------------------
// |更多功能可联系QQ314688769
// +----------------------------------------------------------------------
namespace api\cveadmin\service;
use api\cveadmin\model\UserModel;
use api\cveadmin\model\RoleModel;
class UserService
{
    /** 
     * @description: 统计用户数量
     * @return int
     */    
    public function countUsers()
    {
        $count = UserModel::count();
        return $count;
    }

    /** 
     * @description: 根据角色ID|部门ID获取管理用户
     * @param int $roleId
     * @return {*} $result
     */    
    public function getAdminUsersByRoleId($roleId)
    {
        $result = RoleModel::with(['user'=>function($query){
            $query->order('id Desc');//用户倒序排列
        }])->where('id',$roleId)->select()->toArray();
        return $result;
    }
}
